package com.six.JacksonOperation;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.six.entity.Person;

import java.io.FileInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * ClassName:JsonToJava
 * Package:com.six
 * Description
 *
 * @Author:@wenxueshi
 * @Create:2023/7/27 - 22:48
 * @Version:v1.0
 */
//JSON二进制数组-->Java对象
public class JsonToJava4 {

    public static void main(String[] args) throws IOException {
        String json = "{\"name\":\"swx\",\"age\":18,\"skillsList\":[\"java\",\"python\",\"php\"]}";
        byte[] bytes = json.getBytes(StandardCharsets.UTF_8);
        ObjectMapper objectMapper = new ObjectMapper();
        Person person = objectMapper.readValue(bytes, Person.class);
        //Person(name=swx, age=18, skillsList=[java, python, php])
        System.out.println(person);
    }
}
